package com.centaline.androidsalesblog.rx.database;

import com.centaline.androidsalesblog.model.businissobject.DropBo;
import com.centaline.androidsalesblog.model.businissobject.HistoryBo;
import com.centaline.androidsalesblog.model.businissobject.HistoryInDateBo;
import com.centaline.androidsalesblog.model.businissobject.RongUserInfoBo;
import com.centaline.androidsalesblog.model.databaseobject.BizUnitDo;
import com.centaline.androidsalesblog.model.databaseobject.CityCenterDo;
import com.centaline.androidsalesblog.model.databaseobject.CityDo;
import com.centaline.androidsalesblog.model.databaseobject.RailLineDo;
import com.centaline.androidsalesblog.model.databaseobject.RegionDo;
import com.centaline.androidsalesblog.model.databaseobject.SearchDataDo;
import com.centaline.androidsalesblog.model.databaseobject.StaffDo;
import com.centaline.androidsalesblog.model.databaseobject.UserDo;

import org.litepal.crud.DataSupport;

import java.util.ArrayList;

import rx.Observable;

/**
 * 数据库
 * Created by guilin on 16/1/25.
 */
public final class RxDataBase {

    private RxDataBase() {
        //Utility Class
    }

    /**
     * 城市列表
     */
    public static Observable<ArrayList<CityDo>> cityList() {
        return Observable.create(new CityListOnSubscribe());
    }

    /**
     * 租售区域
     */
    public static Observable<ArrayList<RegionDo>> getSaleRegions() {
        return Observable.create(new SaleRegionOnSubscribe());
    }

    /**
     * 地铁
     */
    public static Observable<ArrayList<RailLineDo>> getMetro() {
        return Observable.create(new MetroOnSubscribe());
    }

    /**
     * SearchData
     *
     * @param name SearchData名字(Name字段)
     * @return Observable
     */
    public static Observable<ArrayList<SearchDataDo>> getSearchData(String name) {
        return Observable.create(new SearchDataOnSubscribe(name));
    }

    /**
     * 附近
     *
     * @return Observable
     */
    public static Observable<DropBo> nearby() {
        return Observable.create(new NearByOnSubscribe());
    }


    /**
     * 存储足迹数据
     */
    public static Observable<Void> fpHistorySave(int type, String resourceId, DataSupport dataSupport) {
        return Observable.create(new FpHistorySaveOnSubscribe(type, resourceId, dataSupport));
    }

    /**
     * 获取足迹数据
     */
    public static Observable<ArrayList<HistoryInDateBo>> getFpHistory() {
        return Observable.create(new FpHistoryOnSubscribe());
    }

    /**
     * 足迹数量
     */
    public static Observable<Integer> fpHistoryCount() {
        return Observable.create(new FpHistoryCountOnSubscribe());
    }

    /**
     * 删除足迹数据
     */
    public static Observable<Boolean> deleteFpHistory(ArrayList<HistoryBo> arrayList) {
        return Observable.create(new FootDeleteOnSubscribe(arrayList));
    }

    /**
     * 获取城市中心信息(经纬度)
     */
    public static Observable<CityCenterDo> cityCenterDo() {
        return Observable.create(new CityCenterOnSubscribe());
    }

    /**
     * 获取BizUnit
     */
    public static Observable<BizUnitDo> getBizUnit() {
        return Observable.create(new BizUnitOnSubscribe());
    }

    /**
     * 新盘区域
     */
    public static Observable<ArrayList<DropBo>> getNewEstRegion() {
        return Observable.create(new NewEstRegionDropOnSubscribe());
    }

    /**
     * 获取最近联系人数据
     */
    public static Observable<ArrayList<StaffDo>> getHistoryStaffs() {
        return Observable.create(new HistoryStaffsGetOnSubscribe());
    }

    /**
     * 保存联系人
     */
    public static Observable<Void> saveStaff(StaffDo staffDo) {
        return Observable.create(new HistoryStaffsSaveOnSubscribe(staffDo));
    }

    /**
     * 删除联系人
     */
    public static Observable<Boolean> deleteStaff(StaffDo staffDo) {
        return Observable.create(new HistoryStaffsDeleteOnSubscribe(staffDo));
    }

    /**
     * 用户信息保存
     */
    public static Observable<Boolean> saveUser(UserDo userDo) {
        return Observable.create(new UserSaveOnSubScribe(userDo));
    }

    /**
     * 删除用户信息
     */
    public static Observable<Boolean> deleteUser() {
        return Observable.create(new UserDeleteOnSubscribe());
    }

    /**
     * 获取用户信息
     */
    public static Observable<UserDo> getUser() {
        return Observable.create(new UserGetOnSubscribe());
    }

    /**
     * 融云聊天用户信息
     */
    public static Observable<RongUserInfoBo> rongUserInfo(String targetId) {
        return Observable.create(new RongUserInfoOnSubscribe(targetId));
    }

    /**
     * 保存浏览id
     */
    public static Observable<Void> saveBrowse(int type, String id) {
        return Observable.create(new BrowseSaveOnSubscribe(type, id));
    }

    /**
     * 获取浏览id
     */
    public static Observable<ArrayList<String>> getBrowseIds(int type) {
        return Observable.create(new BrowseIdsOnSubscribe(type));
    }
}
